package bb.lanxing.lib.devices.ble.ble.characteristic.hr;

import android.bluetooth.BluetoothGatt;
import android.bluetooth.BluetoothGattCharacteristic;
import android.content.Intent;
import bb.lanxing.lib.base.BaseApplication;
import bb.lanxing.lib.devices.ble.BLEAttributes;
import bb.lanxing.lib.devices.ble.BleCons;
import bb.lanxing.lib.devices.ble.ble.base.BaseBleCharacteristic;
import bb.lanxing.lib.devices.ble.ble.base.BaseBleService;
import java.util.UUID;

import bb.lanxing.lib.devices.utils.ByteUtils;
import bb.lanxing.lib.kt.ByteExtKt;
import kotlin.Metadata;
import kotlin.UByte;
import kotlin.jvm.internal.Intrinsics;

public final class HeartRateAlertNotifyCharacteristics extends BaseBleCharacteristic {
    public HeartRateAlertNotifyCharacteristics(BaseBleService bleService) {
        super(bleService);
//        Intrinsics.checkNotNullParameter(bleService, "bleService");
    }

    @Override
    public UUID targetUUID() {
        UUID fromString = UUID.fromString(BLEAttributes.BLE_HEART_RATE_WARN_NOTIFY);
//        Intrinsics.checkNotNullExpressionValue(fromString, "fromString(BLEAttributes…E_HEART_RATE_WARN_NOTIFY)");
        return fromString;
    }

    @Override
    public void onValueUpdate(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
//        Intrinsics.checkNotNullParameter(gatt, "gatt");
//        Intrinsics.checkNotNullParameter(characteristic, "characteristic");
        byte[] value = characteristic.getValue();
        int m2872constructorimpl = ByteUtils.byte2Int(value[2]) & 255;//ByteUtils.toHex(value[2]) & 255;



        boolean z = false;
        if (m2872constructorimpl == 9) {
            int m2872constructorimpl2 = ByteUtils.byte2Int(value[3]) & 255;
            BaseApplication context = getBleService().getDevice().getContext();
            Intent intent = new Intent(BleCons.ACTION_HERATRATE_ALERT_WARN_SET_STATUS);
            intent.putExtra(BleCons.EXTRA_HERATRATE_BELT_WARN_SET_STATUS, m2872constructorimpl2 == 1);
            context.sendBroadcast(intent);
        }
        if (m2872constructorimpl == 10) {
            int m2872constructorimpl3 = ByteUtils.byte2Int(value[3]) & 255;
            ByteUtils.byte2Int(value[5]);
            BaseApplication context2 = getBleService().getDevice().getContext();
            Intent intent2 = new Intent(BleCons.ACTION_HERATRATE_ALERT_WARN);
            intent2.putExtra(BleCons.EXTRA_HERATRATE_BELT_WARN, (ByteUtils.byte2Int(value[4]) & 255) + "");
            intent2.putExtra(BleCons.EXTRA_HERATRATE_BELT_WARN_STATUS, m2872constructorimpl3 == 1);
            context2.sendBroadcast(intent2);
        }
        if (m2872constructorimpl == 11) {
            int m2872constructorimpl4 = ByteUtils.byte2Int(value[3]) & 255;
            ByteUtils.byte2Int(value[4]);
            BaseApplication context3 = getBleService().getDevice().getContext();
            Intent intent3 = new Intent(BleCons.ACTION_HERATRATE_ALERT_WARN_CLOSE_STATUS);
            if (m2872constructorimpl4 == 1) {
                z = true;
            }
            intent3.putExtra(BleCons.EXTRA_HERATRATE_BELT_WARN_CLOSE_STATUS, z);
            context3.sendBroadcast(intent3);
        }
    }
}
